refactor: add isnan guards#13362
Merged
Merged
Conversation
Propagates fix from 2671115 ("refactor: add explicit `isnan` guards") to sibling distribution packages that guard `<=` on shape/rate parameters but do not explicitly reject `NaN`. Applied verbatim across `gamma`, `beta`, `betaprime`, `f`, and `invgamma` summary statistics (`mean`, `median`, `mode`, `variance`, `stdev`, `skewness`, `kurtosis`, `entropy` — where present). Ref: 2671115
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
approved these changes
Jul 7, 2026
isnan guards across stats/base/dists distributionsisnan guards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Propagating fixes merged to
developbetween 2026-07-06 15:53 -0700 and 2026-07-07 00:50 -0700 to sibling packages.refactor: add explicit isnan guards— 2671115Propagates the explicit
isnanguard pattern from 2671115 ("refactor: add explicitisnanguards" inpareto-type1/{mean,median}) to sibling distribution packages, replacing implicit reliance onNaN <= 0.0evaluating tofalsewith explicitisnan( alpha ) || isnan( beta )rejection. Forbetaprime/mode, the fix is not defensive-only: with the old guard,mode( 0.5, NaN )returned0.0instead ofNaN, because the follow-upalpha < 1.0branch fired past the failed rejection.Target packages:
stats/base/dists/gamma/{mean,mode,variance,stdev,entropy}stats/base/dists/beta/{mean,median,mode,variance,stdev,skewness,kurtosis,entropy}stats/base/dists/f/{mode,variance,stdev,skewness,kurtosis}stats/base/dists/invgamma/{mean,mode,variance,stdev,entropy}stats/base/dists/betaprime/{mean,mode}Related Issues
No.
Questions
No.
Other
Validation
lib/node_modules/@stdlib/stats/base/dists/*/{mean,median,mode,variance,stdev,skewness,kurtosis,entropy,mgf}/lib/main.js.isnanrequire placement (first in// MODULES //), guard-block indentation, parameter-order preservation, and threshold preservation match the source commit and the existing already-fixed sibling files (t/entropy,rayleigh/entropy,triangular/entropy,weibull/entropy).Deliberately excluded
>=(arcsine, uniform) — 9 files. The pattern signature differs from the source commit and the maintainer intent for>=bounds is not established by 2671115.lognormal/stdev,t/stdev,chisquare/median).!isInteger(...)/!isNonNegativeInteger(...)(hypergeometric, discrete-uniform families), which reject NaN inherently.stats/base/dists/pareto-type1/*— source of the fix; already covered.547176ec,9c313057) had zero remaining unfixed sites in the repo; ternary-parens propagation (563772fc) had zero remaining unfixed sites;dlast-index-of/slast-index-ofcollapse (ba80db9c) — siblinglast-index-ofpackages already usereturn N - 1 - idx;;Float16Arrayindex-signature fix (6b88a637) — pattern does not extend toComplex64Array/Complex128Array/BooleanArray(non-native, no numeric index access).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by an automated stdlib fix-propagation routine: the last 24h of commits merged to
developwere parsed for propagatable fix patterns; each candidate pattern's structural signature was searched across sibling packages; each candidate site was reviewed by two independent opus validation agents and a sonnet style-consistency agent, with only sites passing all three advancing to the propagation branch. Each patch was hand-verified against the approved diff before commit.Generated by Claude Code